﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeatherSystem.Data.Response
{
    abstract class ResponseMessageBase
    {
        protected virtual ResponseMessageType msgType { get; } = ResponseMessageType.Text;
        public string ToUserName { get; set; }
        public string FromUserName { get; set; }
        public long CreateTime { get; set; }
        public string MsgType
        {
            get
            {
                switch (msgType)
                {
                    case ResponseMessageType.Text:
                        return AddCdataMark("text");
                    case ResponseMessageType.Image:
                        return AddCdataMark("image");
                    case ResponseMessageType.Link:
                        return AddCdataMark("link");
                    case ResponseMessageType.Location:
                        return AddCdataMark("location");
                    case ResponseMessageType.ShortVidio:
                        return AddCdataMark("shortvidio");
                    case ResponseMessageType.Vidio:
                        return AddCdataMark("vidio");
                    case ResponseMessageType.Voice:
                        return AddCdataMark("voice");
                    default:
                        return AddCdataMark("null");
                }
            }
        }
        public ResponseMessageBase(string to,string from,long time)
        {
            ToUserName = to;
            FromUserName = from;
            CreateTime = time;
        }
        protected string AddCdataMark(string data)
        {
            return string.Format("<![CDATA[{0}]]>", data);
        }
        
        public ResponseMessageType GetMessageType()
        {
            return msgType;
        }
        public abstract JObject GetJobject();
    }

    enum ResponseMessageType
    {
        Text,
        Image,
        Voice,
        Vidio,
        ShortVidio,
        Location,
        Link
    }
}
